<?php
include '../../include/dbFunctions.php';
include ("../../include/function.php");
require ("../../include/class.phpmailer.php");

$contact = "SELECT * FROM contact_school";
$contact = executeSelectQuery($contact);

$true = 0;
for ($i = 0; $i < count($contact); $i++){
    
              $to = $contact[$i]['contact_email'];
                $subject = "Your new JA account";
                $message = <<<HERE
Welcome to JA Singapore. Here is your new account's details. Please login to the system and reset your password as soon as possible.
    
Email:$to              
Password: volunteer$i

Please lick to the link below to process to our website:
http://http://scheduler.ja.org.sg


Thank you for your support of JA Programs.

Best regards,
Ng. Hau Yee (Ms.)
Director
Junior Achievement Singapore


* This is an auto-generated email. Please do not reply
If you have any questions, please email hauyee.ng@ja.org

* It is an auto-generated email. Please do not reply
Any question, please email hauyee.ng@ja.org


HERE;
                $headers = "From: hauyee.ng@ja.org" . "\r\n" .
                        "Reply-To: hauyee.ng@ja.org" . "\r\n" .
                        "X-Mailer: PHP/" . phpversion();

                $sendresult = mail($to, $subject, $message, $headers);
    
    if ($sendresult){
        $true = $true+0;
    }
    else{
        $true = $true+1;
    }
    
}
if ($true == 0){
    echo "Done!";
}
else{
    echo "Error!";
}

?>